import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:tender_flutter/constant/theme_colors.dart';
import 'package:tender_flutter/page/track/model/track_entity.dart';
import 'package:tender_flutter/utils/screen_adaper.dart';

class TrackListCell extends StatelessWidget {
  const TrackListCell({Key key, this.data, this.onTap, this.deleteCallback})
      : super(key: key);

  final TrackList data;
  final GestureTapCallback onTap;
  final GestureTapCallback deleteCallback;

  @override
  Widget build(BuildContext context) {
    return Slidable(
      actionPane: SlidableDrawerActionPane(),
      actionExtentRatio: 0.2,
      secondaryActions: <Widget>[
        IconSlideAction(
          caption: '取消追踪',
          color: ThemeColors.colorType30,
          icon: Icons.cancel,
          onTap: deleteCallback,
        ),
      ],
      child: _initCell(),
    );
  }

  Widget _initCell() {
    return GestureDetector(
        onTap: onTap,
        child: Container(
          width: double.infinity,
          color: ThemeColors.colorWhite,
          child: Row(
            children: <Widget>[
              Container(
                width: ScreenAdapter.width(100),
                height: ScreenAdapter.width(100),
                margin: EdgeInsets.only(
                    left: ScreenAdapter.width(30),
                    right: ScreenAdapter.width(18)),
                alignment: Alignment.center,
                decoration: BoxDecoration(
                    color: ThemeColors.colorType6,
                    borderRadius:
                        BorderRadius.circular(ScreenAdapter.width(14))),
                child: Text("企",
                    style: TextStyle(
                        color: ThemeColors.colorWhite,
                        fontSize: ScreenAdapter.sp(40),
                        fontWeight: FontWeight.bold)),
              ),
              Expanded(
                  child: Container(
                width: double.infinity,
                margin: EdgeInsets.only(
                    top: ScreenAdapter.height(30),
                    bottom: ScreenAdapter.height(30),
                    right: ScreenAdapter.width(30)),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    Text(
                      data.companyName ?? "-",
                      overflow: TextOverflow.ellipsis,
                      maxLines: 1,
                      style: TextStyle(
                          color: ThemeColors.colorType1,
                          fontSize: ScreenAdapter.sp(32),
                          fontWeight: FontWeight.w600),
                    ),
                    SizedBox(height: ScreenAdapter.height(20)),
                    Row(
//                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: <Widget>[
                        Text('信用代码：${data.creditCode}',
                            style: TextStyle(
                                color: ThemeColors.colorType7,
                                fontSize: ScreenAdapter.sp(28))),
                      ],
                    )
                  ],
                ),
              ))
            ],
          ),
        ));
  }
}
